﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Threading;
using System.Globalization;

//NES MAPPER 1.0
//programmed by Shawn M. Crawford 12/2008

namespace nesmapperprogram
{
    public partial class mainForm : Form
    {
        public mainForm()
        {
            InitializeComponent();
        }
        string openFlagString;
        string filename;
        string path;

        private delegate void puttext(object sender, string p);
        private delegate void putvalue(object sender, int value);

        private void put(object sender, string p)
        {
            if (sender == (object)statusLabel)
            {
                ((Control)sender).Text = p;
            }
            else
            {
                ((Control)sender).Text += p;
            }
        }


        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {

            if (openFlagString == "0")
            {
                OpenFileDialog ofd = new OpenFileDialog();
                ofd.Title = "Open file...";
                ofd.Filter = "NES files (*.nes)|*.nes|BIN files(*.bin)|*.bin|All files (*.*)|*.*";
                ofd.Multiselect = false;
                 
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    nesFileNameTextBox.Text = ofd.FileName;
                }
            }

            //if we cancel the dialog it will crash, we cant set this to dialogresult or
            //it wont reload the rom after we clean it or change it, so we just check
            //for data in the nesfilenametextbox

            if (nesFileNameTextBox.Text != "")
            {
                path = nesFileNameTextBox.Text;
                filename = nesFileNameTextBox.Text.Substring(nesFileNameTextBox.Text.LastIndexOf('\\') + 1);

                //enable the options after rom is loaded
                remove16byteHeaderCheckBox.Enabled = true;
                analyzeRomButton.Enabled = true;
                analyzeRomToolStripMenuItem.Enabled = true;
                cleanRomButton.Enabled = true;
                nesButton.Enabled = true;

                titleLabel.Text = "File: [ " + filename + " ]";
                //off = 0;

                asciiTextBox.Text = "";
                hexTextBox.Text = "";

                Thread th = new Thread(new ThreadStart(loadfile));//calls the loadfile function
                th.Start();
            }

            //reset the openflag
            openFlagString = "0";

            //cant seem to get this to run correctly the first time
            //analyzeRomButton_Click(sender, e);
        }

        private void modifyoffset(int off)
        {
            string s = titleLabel.Text;
            s = s.Substring(0, s.LastIndexOf('['));
            s += "[current offset: " + off + " (hex: " + off.ToString("X") + ")]";
            titleLabel.Text = s;
        }


        private void loadfile()
        {

            StreamReader sr = new StreamReader(path, Encoding.Default);
            char[] buff1;
            string asciiString;

            int counterOneInt, counterTwoInt;
            //start first loop
            while (!sr.EndOfStream)
            {
                buff1 = new char[1024 * 1024 + 1];
                int size2 = sr.ReadBlock(buff1, 0, 1024 * 1024);


                MemoryStream ms = new MemoryStream(size2 + 1);
                MemoryStream ns = new MemoryStream(size2 + 1);

                StreamWriter sw1 = new StreamWriter(ms);
                StreamWriter sw2 = new StreamWriter(ns);
                counterTwoInt = 0;

                //start second loop
                while (counterTwoInt < 16)
                {
                    
                    char[] buff; 
                    int size = 1;
                    
                        buff = new char[] 
                        { 
                            buff1[counterTwoInt] 
                        };

                    counterOneInt = 0;
                    //this splits into 2 bytes 00 01 02 E4 etc
                    while (counterOneInt < size)
                    {
                        //g = ascii key char value?
                        byte g = Encoding.Default.GetBytes(buff, counterOneInt, 1)[0];
                        //n = hex value of the ascii chars
                        string n = g.ToString("x").ToUpper();

                        //if n = 0 then n will = 00
                        if (n.Length == 1) n = "0" + n;
                        //write the hex line
                        sw1.Write(n);

                        //if ascii value of g is between 33 and 122 then n = 00
                        if (!(g >= 33 && g <= 122)) n = "00";

                        //if n = 00 then ascii line is .
                        if (n == "00")
                        {
                            sw2.Write(".");
                        }
                        else
                        //else ascii line = ascii value of the hex string
                        {
                            asciiString = Encoding.Default.GetString(new byte[] { g });
                            sw2.Write(asciiString);
                        }

                        counterOneInt++;
                    }
                    //end third loop
                    counterTwoInt++;
                    sw1.Write(" ");
                    
                }
                //end second loop
                
                
                sw1.Flush();
                sw2.Flush();
                ms.Flush();
                ns.Flush();

                ms.Seek(0, SeekOrigin.Begin);
                ns.Seek(0, SeekOrigin.Begin);

                

                StreamReader h = new StreamReader(ms, Encoding.Default);
                hexTextBox.Invoke(new puttext(put), new object[] { hexTextBox, h.ReadToEnd() });
                h.Close();

                h = new StreamReader(ns, Encoding.Default);
                asciiTextBox.Invoke(new puttext(put), new object[] { asciiTextBox, h.ReadToEnd() });
                h.Close();

                }

            sr.Close();

            
        }


        private void nesButton_Click(object sender, EventArgs e)
        {
            if (remove16byteHeaderCheckBox.Checked)
            {
                //filepath is now the path to the nes rom
                string filePath = @path;
                long offset;
                offset = Convert.ToInt64("14");
                int x = 0;
                int y = @path.Length;
                int errorHandler;
                errorHandler = 0;

                //byte[] nesData;
                //read the nes rom in binary mode
                FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
                BinaryReader br = new BinaryReader(fs, Encoding.Default);


                //nesData = br.ReadBytes((int)fs.Length);

                //
                byte[] nesData  = new byte[br.BaseStream.Length];
                nesData = br.ReadBytes((int)br.BaseStream.Length);
                //
                
                //close
                
                //output the file at the same location and append .bin to it
                FileStream outStream = File.Create(@path + ".bin");
                BinaryWriter bw = new BinaryWriter(outStream);
                
                
                //write the data
                //128k is 131088 bytes
                //we need to set x to 16 to remove the header then add fs.length - 16
                x = 16;
                while ((bw.BaseStream.Position) < (fs.Length - 16))
                {
                    bw.Write(nesData[x]);
                    x = x + 1;
                }

                fs.Close();
                br.Close();
                
                bw.Close();

                chrprgCheckBox.Enabled = true;

                if (chrprgCheckBox.Checked)
                {
                    //Split the rom into PRG & CHR

                    string updatedFilePath = @path + ".bin";
                    offset = Convert.ToInt64("0");
                    int xx = 0;
                    int yy = updatedFilePath.Length;

                    
                    //read the nes rom in binary mode
                    FileStream fs2 = new FileStream(updatedFilePath, FileMode.Open, FileAccess.Read);
                    BinaryReader br2 = new BinaryReader(fs2, Encoding.Default);


                    
                    byte[] nesPrgData = new byte[br2.BaseStream.Length];
                    nesPrgData = br2.ReadBytes((int)br2.BaseStream.Length);

                    //chop out the prg
                    //output the file at the same location and append .prg.bin to it
                    FileStream prgOutStream = File.Create(@path + ".prg.bin");
                    BinaryWriter bw2 = new BinaryWriter(prgOutStream);

                    xx = 0;
                    string prgSizeForSplitString;
                    long prgSizeForSplitLong;

                    prgSizeForSplitString = prgSizeSplitTextBox.Text;
                    prgSizeForSplitLong = 0;

                    try
                    {
                        prgSizeForSplitLong = long.Parse(prgSizeForSplitString);
                    }
                    catch
                    {
                        MessageBox.Show("Program Size Invalid", "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        errorHandler = 1;
                    }

                    try
                    {
                        while ((bw2.BaseStream.Position) != prgSizeForSplitLong)
                        {
                            bw2.Write(nesPrgData[xx]);
                            xx = xx + 1;
                        }
                    }
                    catch
                    {
                        MessageBox.Show("The rom did not split correctly (Incorrect PRG Bytes?).", "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        errorHandler = 1;
                    }

                    fs2.Close();
                    br2.Close();
                    bw2.Close();


                    //chop out the chr
                    FileStream fs3 = new FileStream(updatedFilePath, FileMode.Open, FileAccess.Read);
                    BinaryReader br3 = new BinaryReader(fs3, Encoding.Default);

                    byte[] nesChrData = new byte[br3.BaseStream.Length];
                    nesChrData = br3.ReadBytes((int)br3.BaseStream.Length);
                    FileStream chrOutStream = File.Create(@path + ".chr.bin");
                    BinaryWriter bw3 = new BinaryWriter(chrOutStream);

                    string chrSizeForSplitString;
                    long chrSizeForSplitLong;

                    chrSizeForSplitString = chrSizeSplitTextBox.Text;
                    chrSizeForSplitLong = 0;
                    try
                    {
                        chrSizeForSplitLong = long.Parse(chrSizeForSplitString);
                    }
                    catch
                    {
                        MessageBox.Show("Character Size Invalid", "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        errorHandler = 1;
                    }

                    try
                    {
                        while ((bw3.BaseStream.Position) < (fs3.Length - chrSizeForSplitLong))
                        {
                            bw3.Write(nesChrData[xx]);
                            xx = xx + 1;
                        }
                    }
                    catch
                    {
                        MessageBox.Show("The rom did not split correctly (Incorrect CHR Bytes?).", "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        errorHandler = 1;
                    }

                    fs3.Close();
                    br3.Close();

                    bw3.Close();
                }


                if (errorHandler == 0)
                {
                    MessageBox.Show("Operation Successfully Completed!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        
        }

        private void analyzeRomButton_Click(object sender, EventArgs e)
        {
            //put the hex value into an array so we can figure out the mapper info
            int hexHeaderArrayCounterInt, mapperInt;
            
            string zeroHVS, tweHVS, thitHVS, fiftHVS, sixtHVS, eigtHVS, nintHVS, twen1HVS, twen2HVS,
            hexInformationForArrayString, mapperString, chrSizeString, prgSizeString;

            

            hexInformationForArrayString = hexTextBox.Text;
            char[] hc = hexInformationForArrayString.ToCharArray();

            hexHeaderArrayCounterInt = hc.Length;

            zeroHVS = hc[0].ToString();

            //byte 4
            tweHVS = hc[12].ToString();
            thitHVS = hc[13].ToString();

            prgSizeString = tweHVS + thitHVS;

            switch (prgSizeString)
            {
                case "00":
                    prgSizeTextBox.Text = "0kb (0 x 16kb pages )";
                    prgSizeSplitTextBox.Text = "0000000";
                    break;

                case "01":
                    prgSizeTextBox.Text = "16kb (1 x 16kb pages )";
                    prgSizeSplitTextBox.Text = "0016384";
                    break;

                case "02":
                    prgSizeTextBox.Text = "32kb (2 x 16kb pages )";
                    prgSizeSplitTextBox.Text = "0032768";
                    break;

                case "03":
                    prgSizeTextBox.Text = "48kb (3 x 16kb pages )";
                    prgSizeSplitTextBox.Text = "0049152";
                    break;

                case "04":
                    prgSizeTextBox.Text = "64kb (4 x 16kb pages )";
                    prgSizeSplitTextBox.Text = "0065536";
                    break;

                case "05":
                    prgSizeTextBox.Text = "80kb (5 x 16kb pages )";
                    prgSizeSplitTextBox.Text = "0081920";
                    break;

                case "06":
                    prgSizeTextBox.Text = "96kb (6 x 16kb pages )";
                    prgSizeSplitTextBox.Text = "0098304";
                    break;

                case "07":
                    prgSizeTextBox.Text = "112kb (7 x 16kb pages )";
                    prgSizeSplitTextBox.Text = "0114688";
                    break;

                case "08":
                    prgSizeTextBox.Text = "128kb (8 x 16kb pages )";
                    prgSizeSplitTextBox.Text = "0131072";
                    break;

                case "09":
                    prgSizeTextBox.Text = "144kb (9 x 16kb pages )";
                    prgSizeSplitTextBox.Text = "0147456";
                    break;

                case "0A":
                    prgSizeTextBox.Text = "160kb (10 x 16kb pages )";
                    prgSizeSplitTextBox.Text = "0163840";
                    break;

                case "0B":
                    prgSizeTextBox.Text = "176kb (11 x 16kb pages )";
                    prgSizeSplitTextBox.Text = "0180224";
                    break;

                case "0C":
                    prgSizeTextBox.Text = "192kb (12 x 16kb pages )";
                    prgSizeSplitTextBox.Text = "0196608";
                    break;

                case "0D":
                    prgSizeTextBox.Text = "208kb (13 x 16kb pages )";
                    prgSizeSplitTextBox.Text = "0212992";
                    break;

                case "0E":
                    prgSizeTextBox.Text = "224kb (14 x 16kb pages )";
                    prgSizeSplitTextBox.Text = "0229376";
                    break;

                case "0F":
                    prgSizeTextBox.Text = "240kb (15 x 16kb pages )";
                    prgSizeSplitTextBox.Text = "0245760";
                    break;

                case "10":
                    prgSizeTextBox.Text = "256kb (16 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0262144";
                    break;

                case "11":
                    prgSizeTextBox.Text = "272kb (17 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0278528";
                    break;

                case "12":
                    prgSizeTextBox.Text = "288kb (18 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0294912";
                    break;

                case "13":
                    prgSizeTextBox.Text = "304kb (19 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0311296";
                    break;

                case "14":
                    prgSizeTextBox.Text = "320kb (20 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0327680";
                    break;

                case "15":
                    prgSizeTextBox.Text = "336kb (21 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0344064";
                    break;

                case "16":
                    prgSizeTextBox.Text = "352kb (22 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0360448";
                    break;

                case "17":
                    prgSizeTextBox.Text = "368kb (23 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0376832";
                    break;

                case "18":
                    prgSizeTextBox.Text = "384kb (24 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0393216";
                    break;

                case "19":
                    prgSizeTextBox.Text = "400kb (25 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0409600";
                    break;

                case "1A":
                    prgSizeTextBox.Text = "416kb (26 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0425984";
                    break;

                case "1B":
                    prgSizeTextBox.Text = "432kb (27 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0442368";
                    break;

                case "1C":
                    prgSizeTextBox.Text = "448kb (28 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0458752";
                    break;

                case "1D":
                    prgSizeTextBox.Text = "464kb (29 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0475136";
                    break;

                case "1E":
                    prgSizeTextBox.Text = "480kb (30 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0491520";
                    break;

                case "1F":
                    prgSizeTextBox.Text = "496kb (31 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0507904";
                    break;

                case "20":
                    prgSizeTextBox.Text = "512kb (32 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0524288";
                    break;

                case "21":
                    prgSizeTextBox.Text = "528kb (33 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0540672";
                    break;

                case "22":
                    prgSizeTextBox.Text = "544kb (34 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0557056";
                    break;

                case "23":
                    prgSizeTextBox.Text = "560kb (35 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0573440";
                    break;

                case "24":
                    prgSizeTextBox.Text = "576kb (36 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0589824";
                    break;

                case "25":
                    prgSizeTextBox.Text = "592kb (37 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0606208";
                    break;

                case "26":
                    prgSizeTextBox.Text = "608kb (38 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0622592";
                    break;

                case "27":
                    prgSizeTextBox.Text = "624kb (39 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0638976";
                    break;

                case "28":
                    prgSizeTextBox.Text = "640kb (40 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0655360";
                    break;

                case "29":
                    prgSizeTextBox.Text = "656kb (41 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0671744";
                    break;

                case "2A":
                    prgSizeTextBox.Text = "672kb (42 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0688128";
                    break;

                case "2B":
                    prgSizeTextBox.Text = "688kb (43 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0704512";
                    break;

                case "2C":
                    prgSizeTextBox.Text = "704kb (44 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0720896";
                    break;

                case "2D":
                    prgSizeTextBox.Text = "720kb (45 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0737280";
                    break;

                case "2E":
                    prgSizeTextBox.Text = "736kb (46 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0753664";
                    break;

                case "2F":
                    prgSizeTextBox.Text = "752kb (47 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0770048";
                    break;

                case "30":
                    prgSizeTextBox.Text = "768kb (48 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0786432";
                    break;

                case "31":
                    prgSizeTextBox.Text = "784kb (49 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0802816";
                    break;

                case "32":
                    prgSizeTextBox.Text = "800kb (50 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0819200";
                    break;

                case "33":
                    prgSizeTextBox.Text = "816kb (51 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0835584";
                    break;

                case "34":
                    prgSizeTextBox.Text = "832kb (52 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0851968";
                    break;

                case "35":
                    prgSizeTextBox.Text = "848kb (53 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0868352";
                    break;

                case "36":
                    prgSizeTextBox.Text = "864kb (54 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0884736";
                    break;

                case "37":
                    prgSizeTextBox.Text = "880kb (55 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0901120";
                    break;

                case "38":
                    prgSizeTextBox.Text = "896kb (56 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0917504";
                    break;

                case "39":
                    prgSizeTextBox.Text = "912kb (57 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0933888";
                    break;

                case "3A":
                    prgSizeTextBox.Text = "928kb (58 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0950272";
                    break;

                case "3B":
                    prgSizeTextBox.Text = "944kb (59 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0966656";
                    break;

                case "3C":
                    prgSizeTextBox.Text = "960kb (60 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0983040";
                    break;

                case "3D":
                    prgSizeTextBox.Text = "976kb (61 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "0999424";
                    break;

                case "3E":
                    prgSizeTextBox.Text = "992kb (62 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "1015808";
                    break;

                case "3F":
                    prgSizeTextBox.Text = "1008kb (63 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "1032192";
                    break;

                case "40":
                    prgSizeTextBox.Text = "1024kb (64 x 16kb pages)";
                    prgSizeSplitTextBox.Text = "1048576";
                    break;
            }
            /*
             * 4 = PRG (Hex number depends on size of PRG file)-/-- (See Sect. 4)

[PRG - (Range 1 x 16kb pages -> 64 x 16kb pages)]
-There is a BARE MINIMUM required for PRG which is 1 x 16kb pages!

* NOTE: To figure out the exact size in bytes each of these pages are worth
        just start at 1 x 16kb pages (aka: 16384 bytes) and just keep adding
        16384 more for each "page" higher.

(1 x 16kb pages)  = 01     (2 x 16kb pages)  = 02     (3 x 16kb pages)  = 03
(4 x 16kb pages)  = 04     (5 x 16kb pages)  = 05     (6 x 16kb pages)  = 06
(7 x 16kb pages)  = 07     (8 x 16kb pages)  = 08     (9 x 16kb pages)  = 09
(10 x 16kb pages) = 0A     (11 x 16kb pages) = 0B     (12 x 16kb pages) = 0C
(13 x 16kb pages) = 0D     (14 x 16kb pages) = 0E     (15 x 16kb pages) = 0F
(16 x 16kb pages) = 10     (17 x 16kb pages) = 11     (18 x 16kb pages) = 12
(19 x 16kb pages) = 13     (20 x 16kb pages) = 14     (21 x 16kb pages) = 15
(22 x 16kb pages) = 16     (23 x 16kb pages) = 17     (24 x 16kb pages) = 18
(25 x 16kb pages) = 19     (26 x 16kb pages) = 1A     (27 x 16kb pages) = 1B
(28 x 16kb pages) = 1C     (29 x 16kb pages) = 1D     (30 x 16kb pages) = 1E
(31 x 16kb pages) = 1F     (32 x 16kb pages) = 20     (33 x 16kb pages) = 21
(34 x 16kb pages) = 22     (35 x 16kb pages) = 23     (36 x 16kb pages) = 24
(37 x 16kb pages) = 25     (38 x 16kb pages) = 26     (39 x 16kb pages) = 27
(40 x 16kb pages) = 28     (41 x 16kb pages) = 29     (42 x 16kb pages) = 2A
(43 x 16kb pages) = 2B     (44 x 16kb pages) = 2C     (45 x 16kb pages) = 2D
(46 x 16kb pages) = 2E     (47 x 16kb pages) = 2F     (48 x 16kb pages) = 30 
(49 x 16kb pages) = 31     (50 x 16kb pages) = 32     (51 x 16kb pages) = 33
(52 x 16kb pages) = 34     (53 x 16kb pages) = 35     (54 x 16kb pages) = 36
(55 x 16kb pages) = 37     (56 x 16kb pages) = 38     (57 x 16kb pages) = 39
(58 x 16kb pages) = 3A     (59 x 16kb pages) = 3B     (60 x 16kb pages) = 3C
(61 x 16kb pages) = 3D     (62 x 16kb pages) = 3E     (63 x 16kb pages) = 3F
(64 x 16kb pages) = 40
*/



            //byte 5
            fiftHVS = hc[15].ToString();
            sixtHVS = hc[16].ToString();
            chrSizeString = fiftHVS + sixtHVS;

            switch (chrSizeString)
            {
                case "00":
                    chrSizeTextBox.Text = "0kb (0 x 8kb pages )";
                    chrSizeSplitTextBox.Text = "0000000";
                    break;

                case "01":
                    chrSizeTextBox.Text = "8kb (1 x 8kb pages )";
                    chrSizeSplitTextBox.Text = "0008192";
                    break;

                case "02":
                    chrSizeTextBox.Text = "16kb (2 x 8kb pages )";
                    chrSizeSplitTextBox.Text = "0016384";
                    break;

                case "03":
                    chrSizeTextBox.Text = "24kb (3 x 8kb pages )";
                    chrSizeSplitTextBox.Text = "0024576";
                    break;

                case "04":
                    chrSizeTextBox.Text = "32kb (4 x 8kb pages )";
                    chrSizeSplitTextBox.Text = "0032768";
                    break;

                case "05":
                    chrSizeTextBox.Text = "40kb (5 x 8kb pages )";
                    chrSizeSplitTextBox.Text = "0040960";
                    break;

                case "06":
                    chrSizeTextBox.Text = "48kb (6 x 8kb pages )";
                    chrSizeSplitTextBox.Text = "0049152";
                    break;

                case "07":
                    chrSizeTextBox.Text = "56kb (7 x 8kb pages )";
                    chrSizeSplitTextBox.Text = "0057344";
                    break;

                case "08":
                    chrSizeTextBox.Text = "64kb (8 x 8kb pages )";
                    chrSizeSplitTextBox.Text = "0065536";
                    break;

                case "09":
                    chrSizeTextBox.Text = "72kb (9 x 8kb pages )";
                    chrSizeSplitTextBox.Text = "0073728";
                    break;

                case "0A":
                    chrSizeTextBox.Text = "80kb (10 x 8kb pages )";
                    chrSizeSplitTextBox.Text = "0081920";
                    break;

                case "0B":
                    chrSizeTextBox.Text = "88kb (11 x 8kb pages )";
                    chrSizeSplitTextBox.Text = "0090112";
                    break;

                case "0C":
                    chrSizeTextBox.Text = "96kb (12 x 8kb pages )";
                    chrSizeSplitTextBox.Text = "0098304";
                    break;

                case "0D":
                    chrSizeTextBox.Text = "104kb (13 x 8kb pages )";
                    chrSizeSplitTextBox.Text = "0106496";
                    break;

                case "0E":
                    chrSizeTextBox.Text = "112kb (14 x 8kb pages )";
                    chrSizeSplitTextBox.Text = "0114688";
                    break;

                case "0F":
                    chrSizeTextBox.Text = "120kb (15 x 8kb pages )";
                    chrSizeSplitTextBox.Text = "0122880";
                    break;

                case "10":
                    chrSizeTextBox.Text = "128kb (16 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0131072";
                    break;

                case "11":
                    chrSizeTextBox.Text = "136kb (17 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0139264";
                    break;

                case "12":
                    chrSizeTextBox.Text = "144kb (18 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0147456";
                    break;

                case "13":
                    chrSizeTextBox.Text = "152kb (19 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "155648";
                    break;

                case "14":
                    chrSizeTextBox.Text = "160kb (20 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0163840";
                    break;

                case "15":
                    chrSizeTextBox.Text = "168kb (21 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0172032";
                    break;

                case "16":
                    chrSizeTextBox.Text = "176kb (22 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0180224";
                    break;

                case "17":
                    chrSizeTextBox.Text = "184kb (23 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0188416";
                    break;

                case "18":
                    chrSizeTextBox.Text = "192kb (24 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0196608";
                    break;

                case "19":
                    chrSizeTextBox.Text = "200kb (25 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0204800";
                    break;

                case "1A":
                    chrSizeTextBox.Text = "208kb (26 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0212992";
                    break;

                case "1B":
                    chrSizeTextBox.Text = "216kb (27 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0221184";
                    break;

                case "1C":
                    chrSizeTextBox.Text = "224kb (28 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0229376";
                    break;

                case "1D":
                    chrSizeTextBox.Text = "232kb (29 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0237568";
                    break;

                case "1E":
                    chrSizeTextBox.Text = "240kb (30 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0245760";
                    break;

                case "1F":
                    chrSizeTextBox.Text = "248kb (31 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0253952";
                    break;

                case "20":
                    chrSizeTextBox.Text = "256kb (32 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0262144";
                    break;

                case "21":
                    chrSizeTextBox.Text = "264kb (33 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0270336";
                    break;

                case "22":
                    chrSizeTextBox.Text = "272kb (34 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0278528";
                    break;

                case "23":
                    chrSizeTextBox.Text = "280kb (35 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0286720";
                    break;

                case "24":
                    chrSizeTextBox.Text = "288kb (36 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0294912";
                    break;

                case "25":
                    chrSizeTextBox.Text = "296kb (37 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0303104";
                    break;

                case "26":
                    chrSizeTextBox.Text = "304kb (38 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0311296";
                    break;

                case "27":
                    chrSizeTextBox.Text = "312kb (39 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0319488";
                    break;

                case "28":
                    chrSizeTextBox.Text = "320kb (40 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0327680";
                    break;

                case "29":
                    chrSizeTextBox.Text = "328kb (41 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0335872";
                    break;

                case "2A":
                    chrSizeTextBox.Text = "336kb (42 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0344064";
                    break;

                case "2B":
                    chrSizeTextBox.Text = "344kb (43 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0352256";
                    break;

                case "2C":
                    chrSizeTextBox.Text = "352kb (44 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0360448";
                    break;

                case "2D":
                    chrSizeTextBox.Text = "360kb (45 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0368640";
                    break;

                case "2E":
                    chrSizeTextBox.Text = "368kb (46 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0376832";
                    break;

                case "2F":
                    chrSizeTextBox.Text = "376kb (47 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0385024";
                    break;

                case "30":
                    chrSizeTextBox.Text = "384kb (48 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0393216";
                    break;

                case "31":
                    chrSizeTextBox.Text = "392kb (49 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0401408";
                    break;

                case "32":
                    chrSizeTextBox.Text = "400kb (50 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0409600";
                    break;

                case "33":
                    chrSizeTextBox.Text = "408kb (51 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0417792";
                    break;

                case "34":
                    chrSizeTextBox.Text = "416kb (52 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0425984";
                    break;

                case "35":
                    chrSizeTextBox.Text = "424kb (53 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0434176";
                    break;

                case "36":
                    chrSizeTextBox.Text = "432kb (54 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0442368";
                    break;

                case "37":
                    chrSizeTextBox.Text = "440kb (55 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0450560";
                    break;

                case "38":
                    chrSizeTextBox.Text = "448kb (56 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0458752";
                    break;

                case "39":
                    chrSizeTextBox.Text = "456kb (57 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0466944";
                    break;

                case "3A":
                    chrSizeTextBox.Text = "464kb (58 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0475136";
                    break;

                case "3B":
                    chrSizeTextBox.Text = "472kb (59 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0483328";
                    break;

                case "3C":
                    chrSizeTextBox.Text = "480kb (60 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0491520";
                    break;

                case "3D":
                    chrSizeTextBox.Text = "488kb (61 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0499712";
                    break;

                case "3E":
                    chrSizeTextBox.Text = "496kb (62 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0507904";
                    break;

                case "3F":
                    chrSizeTextBox.Text = "504kb (63 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0516096";
                    break;

                case "40":
                    chrSizeTextBox.Text = "512kb (64 x 8kb pages)";
                    chrSizeSplitTextBox.Text = "0524288";
                    break;

            }

            
            /*
             * 

5 = CHR (Hex number depends on size of CHR file)/

[CHR - (Range 1 x 8kb pages -> 64 x 8kb pages)]
-There is NO MINIMUM required for CHR data because some games have the CHR
 data imbedded into the PRG info.

* NOTE: To figure out the exact size in bytes each of these pages are worth
        just start at 1 x 8kb pages (aka: 8192 bytes) and just keep adding
        8192 bytes more for each "page" higher.

(1 x 8kb pages)  = 01       (2 x 8kb pages)  = 02       (3 x 8kb pages)  = 03
(4 x 8kb pages)  = 04       (5 x 8kb pages)  = 05       (6 x 8kb pages)  = 06
(7 x 8kb pages)  = 07       (8 x 8kb pages)  = 08       (9 x 8kb pages)  = 09
(10 x 8kb pages) = 0A       (11 x 8kb pages) = 0B       (12 x 8kb pages) = 0C
(13 x 8kb pages) = 0D       (14 x 8kb pages) = 0E       (15 x 8kb pages) = 0F
(16 x 8kb pages) = 10       (17 x 8kb pages) = 11       (18 x 8kb pages) = 12
(19 x 8kb pages) = 13       (20 x 8kb pages) = 14       (21 x 8kb pages) = 15
(22 x 8kb pages) = 16       (23 x 8kb pages) = 17       (24 x 8kb pages) = 18
(25 x 8kb pages) = 19       (26 x 8kb pages) = 1A       (27 x 8kb pages) = 1B
(28 x 8kb pages) = 1C       (29 x 8kb pages) = 1D       (30 x 8kb pages) = 1E
(31 x 8kb pages) = 1F       (32 x 8kb pages) = 20       (33 x 8kb pages) = 21
(34 x 8kb pages) = 22       (35 x 8kb pages) = 23       (36 x 8kb pages) = 24
(37 x 8kb pages) = 25       (38 x 8kb pages) = 26       (39 x 8kb pages) = 27
(40 x 8kb pages) = 28       (41 x 8kb pages) = 29       (42 x 8kb pages) = 2A
(43 x 8kb pages) = 2B       (44 x 8kb pages) = 2C       (45 x 8kb pages) = 2D
(46 x 8kb pages) = 2E       (47 x 8kb pages) = 2F       (48 x 8kb pages) = 30
(49 x 8kb pages) = 31       (50 x 8kb pages) = 32       (51 x 8kb pages) = 33
(52 x 8kb pages) = 34       (53 x 8kb pages) = 35       (54 x 8kb pages) = 36
(55 x 8kb pages) = 37       (56 x 8kb pages) = 38       (57 x 8kb pages) = 39
(58 x 8kb pages) = 3A       (59 x 8kb pages) = 3B       (60 x 8kb pages) = 3C
(61 x 8kb pages) = 3D       (62 x 8kb pages) = 3E       (63 x 8kb pages) = 3F
(64 x 8kb pages) = 40
             */



            //byte 6
            eigtHVS = hc[18].ToString();
            nintHVS = hc[19].ToString();
            //byte 7
            twen1HVS = hc[21].ToString();
            twen2HVS = hc[22].ToString();

            //TODO - setup reg vs extended

            if (extendediNesCheckBox.Checked)
            {
                mapperString = twen1HVS + eigtHVS;
                mapperInt = int.Parse(mapperString, System.Globalization.NumberStyles.HexNumber);
                eigtHVS = mapperInt.ToString();
                //mapper is stored in first part of byte 6 and 7, so in this array it is stored in
                //byte 6: hc[18] and hc[19] byte 7: twen1HVS = hc[21] twen2HVS = hc[22]
                //so we put hc[21] and hc[18] together, convert it to hex, and find a match

                if (eigtHVS == "0")
                {
                    mapperTextBox.Text = "No Mapper [NROM]";
                    exampleRomsTextBox.Text = "Ice Climber, Excitebike, Balloon Fight, Super Mario Bros";
                }
                else if (eigtHVS == "1")
                {
                    mapperTextBox.Text = "1 - Nintendo MMC1 Chipset [MMC1] [S(x)ROM]";
                    exampleRomsTextBox.Text = "Final Fantasy, Mega Man 2, Blaster Master, Metroid, Kid Icarus, Zelda, Zelda 2, Castlevania 2";
                }
                else if (eigtHVS == "2")
                {
                    mapperTextBox.Text = "2 - ROM (PRG) Switch [U(x)ROM]";
                    exampleRomsTextBox.Text = "Mega Man, Castlevania, Contra, Duck Tales, Metal Gear";
                }
                else if (eigtHVS == "3")
                {
                    mapperTextBox.Text = "3 - VROM (CHR) Switch [CNROM]";
                    exampleRomsTextBox.Text = "Solomon's Key, Arkanoid, Arkista's Ring, Bump 'n' Jump, Cybernoid";
                }
                else if (eigtHVS == "4")
                {
                    mapperTextBox.Text = "4 - Nintendo MMC3 Chipset [MMC3] [T(x)ROM], [MMC6] (H(x)ROM]";
                    exampleRomsTextBox.Text = "Mega Man 3, 4, 5, 6, Kirby's Adventure, Gauntlet, Rad Racer 2, Startropics 1, 2 (MMC6), Super Mario Bros. 2, 3";
                }
                else if (eigtHVS == "5")
                {
                    mapperTextBox.Text = "5 - Nintendo MMC5 Chipset [MMC5] [E(x)ROM]";
                    exampleRomsTextBox.Text = "Castlevania 3, Just Breed, Uncharted Waters, Romance of the 3 Kingdoms 2, Laser Invasion, Metal Slader Glory, Uchuu Keibitai SDF, Shin 4 Nin Uchi Mahjong - Yakuman Tengoku";
                }
                else if (eigtHVS == "6")
                {
                    mapperTextBox.Text = "6 - FFE F4XXX Games";
                }
                else if (eigtHVS == "7")
                {
                    mapperTextBox.Text = "7 - 32kb ROM (PRG) Switch [A(x)ROM]";
                    exampleRomsTextBox.Text = "Battletoads, Time Lord, Marble Madness";
                }
                else if (eigtHVS == "8")
                {
                    mapperTextBox.Text = "8 - FFE F3XXX Games";
                }
                else if (eigtHVS == "9")
                {
                    mapperTextBox.Text = "9 - Nintendo MMC2 Chipset [MMC2] [P(x)ROM]";
                    exampleRomsTextBox.Text = "Mike Tyson's Punch Out!!";
                }
                else if (eigtHVS == "10")
                {
                    mapperTextBox.Text = "10 - Nintendo MMC4 Chipset [MMC4]";
                    exampleRomsTextBox.Text = "Fire Emblem";
                }
                else if (eigtHVS == "11")
                {
                    mapperTextBox.Text = "11 - Color Dreams Chipset";
                    exampleRomsTextBox.Text = "Crystal Mines, Metal Fighter";
                }
                else if (eigtHVS == "12")
                {
                    mapperTextBox.Text = "12 - FFE F6XXX Games";
                }
                else if (eigtHVS == "13")
                {
                    mapperTextBox.Text = "13 - [CPROM]";
                    exampleRomsTextBox.Text = "Videomation";
                }
                else if (eigtHVS == "15")
                {
                    mapperTextBox.Text = "15 - 100-in-1 Cart Switch";
                    exampleRomsTextBox.Text = "100-in-1 Contra Function 16";
                }
                else if (eigtHVS == "16")
                {
                    mapperTextBox.Text = "16 - Ban Dai Chipset";
                    exampleRomsTextBox.Text = "Dragon Ball - Dai Maou Jukkatsu, Dragon Ball Z Gaiden, Dragon Ball Z 2, Rokudenashi Blues, Akuma-kun - Makai no Wana";
                }
                else if (eigtHVS == "17")
                {
                    mapperTextBox.Text = "17 - FFE F8XXX Games ";
                }
                else if (eigtHVS == "18")
                {
                    mapperTextBox.Text = "18 - Jaleco SS8806 Chipset";
                    exampleRomsTextBox.Text = "The Lord of King, Magic John, Pizza Pop";
                }
                else if (eigtHVS == "19")
                {
                    mapperTextBox.Text = "19 - Namcot 106 Chipset [N106]";
                    exampleRomsTextBox.Text = "Digital Devil Story - Megami Tensei 2, Final Lap, Rolling Thunder (J), Splatter House, Mappy Kids";
                }
                else if (eigtHVS == "20")
                {
                    mapperTextBox.Text = "20 - Famicom Disk System";
                }
                else if (eigtHVS == "21")
                {
                    mapperTextBox.Text = "21 - Konami VRC4 2a Chipset";
                    exampleRomsTextBox.Text = "Wai Wai World 2, Ganbare Goemon Gaiden 2";
                }
                else if (eigtHVS == "22")
                {
                    mapperTextBox.Text = "22 - Konami VRC4 1b Chipset";
                    exampleRomsTextBox.Text = "Ganbare Pennant Race, TwinBee 3";
                }
                else if (eigtHVS == "23")
                {
                    mapperTextBox.Text = "23 - Konami VRC4 1a Chipset";
                    exampleRomsTextBox.Text = "Wai Wai World";
                }
                else if (eigtHVS == "24")
                {
                    mapperTextBox.Text = "24 - Konami VRC6 Chipset";
                    exampleRomsTextBox.Text = "Akumajou Densetsu";
                }
                else if (eigtHVS == "25")
                {
                    mapperTextBox.Text = "25 - Konami VRC4 Chipset";
                    exampleRomsTextBox.Text = "";
                }
                else if (eigtHVS == "26")
                {
                    mapperTextBox.Text = "26 - VRC6 Variant Chipset";
                    exampleRomsTextBox.Text = "Madara, Esper Dream 2";
                }
                else if (eigtHVS == "32")
                {
                    mapperTextBox.Text = "32 - Irem G-101 Chipset";
                    exampleRomsTextBox.Text = "Image Fight, Major League, Kaiketsu Yanchamaru 2";
                }
                else if (eigtHVS == "33")
                {
                    mapperTextBox.Text = "33 - Taito TC0190/TC0350";
                    exampleRomsTextBox.Text = "Akira, Bakushou!! Jinsei Gekijou, Don Doko Don, Insector X";
                }
                else if (eigtHVS == "34")
                {
                    mapperTextBox.Text = "34 - 32kb ROM (PRG) Switch [B(x)ROM] or [NINA-001]";
                    exampleRomsTextBox.Text = "Darkseed (BxROM), Mashou(BxROM), Impossible Mission 2(NINA-001)";
                }
                else if (eigtHVS == "44")
                {
                    mapperTextBox.Text = "44 - Super Big 7-in-1 [MMC3 Based]";
                    exampleRomsTextBox.Text = "Super Big 7-in-1";
                }
                else if (eigtHVS == "45")
                {
                    mapperTextBox.Text = "45 - Super (X)-in-1 [MMC3 Based]";
                    exampleRomsTextBox.Text = "Super 8-in-1, Super 4-in-1, Super 1000000-in-1";
                }
                else if (eigtHVS == "46")
                {
                    mapperTextBox.Text = "46 - Rumblestation 15-in-1";
                    exampleRomsTextBox.Text = "Rumblestation 15-in-1";
                }
                else if (eigtHVS == "47")
                {
                    mapperTextBox.Text = "47 - Multicart [MMC3 Based]";
                    exampleRomsTextBox.Text = "Super Spike V'Ball + Nintendo World Cup";
                }
                else if (eigtHVS == "48")
                {
                    mapperTextBox.Text = "48 - Mapper 48";
                    exampleRomsTextBox.Text = "Bubble Bobble 2 (J), Don Doko Don 2, Captain Saver";
                }
                else if (eigtHVS == "49")
                {
                    mapperTextBox.Text = "49 - Multicart [MMC3 Based]";
                    exampleRomsTextBox.Text = "Super HIK 4-in-1";
                }
                else if (eigtHVS == "50")
                {
                    mapperTextBox.Text = "50 - Mapper 50";
                    exampleRomsTextBox.Text = "Super Mario Bros. (JU) (Alt Levels)   (SMB2j pirate cart)";
                }
                else if (eigtHVS == "52")
                {
                    mapperTextBox.Text = "52 - Multicart [MMC3 Based]";
                    exampleRomsTextBox.Text = "Mario 7-in-1";
                }
                else if (eigtHVS == "57")
                {
                    mapperTextBox.Text = "57 - Mapper 57 (Multicart)";
                    exampleRomsTextBox.Text = "GK 47-in-1, 6-in-1 (SuperGK)";
                }
                else if (eigtHVS == "58")
                {
                    mapperTextBox.Text = "58 - Mapper 58 (Multicart)";
                    exampleRomsTextBox.Text = "68-in-1 (Game Star), Study and Game 32-in-1";
                }
                else if (eigtHVS == "60")
                {
                    mapperTextBox.Text = "60 - Reset Based 4-in-1 / NROM";
                    exampleRomsTextBox.Text = "Reset Based 4-in-1";
                }
                else if (eigtHVS == "61")
                {
                    mapperTextBox.Text = "61 - Mapper 61 (Multicart)";
                    exampleRomsTextBox.Text = "20-in-1";
                }
                else if (eigtHVS == "62")
                {
                    mapperTextBox.Text = "62 - Mapper 62 (Multicart)";
                    exampleRomsTextBox.Text = "Super 700-in-1";
                }
                else if (eigtHVS == "64")
                {
                    mapperTextBox.Text = "64 - [Tengen Rambo-1]";
                    exampleRomsTextBox.Text = "Klax, Skull and Crossbones, Shinobi";
                }
                else if (eigtHVS == "65")
                {
                    mapperTextBox.Text = "65 - Irem H3001 Chipset";
                    exampleRomsTextBox.Text = "Daiku no Gen San 2, Kaiketsu Yanchamaru 3, Spartan X 2";
                }
                else if (eigtHVS == "66")
                {
                    mapperTextBox.Text = "66 - 74161/32 Chipset [G(x)ROM]";
                    exampleRomsTextBox.Text = "Doraemon, Dragon Power, Gumshoe, Thunder & Lightning, Super Mario Bros. / Duck Hunt";
                }
                else if (eigtHVS == "67")
                {
                    mapperTextBox.Text = "67 - Sunsoft Mapper 3";
                    exampleRomsTextBox.Text = "Fantasy Zone 2 (J), Mito Koumon - Sekai Manyuu Ki";
                }
                else if (eigtHVS == "68")
                {
                    mapperTextBox.Text = "68 - Mapper 68";
                    exampleRomsTextBox.Text = "After Burner 2, Maharaja";
                }
                else if (eigtHVS == "69")
                {
                    mapperTextBox.Text = "69 - Sunsoft Mapper 4, FME-7, Sunsoft 5B";
                    exampleRomsTextBox.Text = "Gimmick!, Batman:  Return of the Joker, Hebereke, Gremlins 2 (J)";
                }
                else if (eigtHVS == "70")
                {
                    mapperTextBox.Text = "70 - 74161/32 Chipset";
                    exampleRomsTextBox.Text = "Family Trainer - Manhattan Police, Family Trainer - Meiro Daisakusen, Kamen Rider Club, Space Shadow";
                }
                else if (eigtHVS == "71")
                {
                    mapperTextBox.Text = "71 - [Camerica Mapper]";
                    exampleRomsTextBox.Text = "MiG 29 - Soviet Fighter, Fire Hawk, The Fantastic Adventures of Dizzy, Bee 52";
                }
                else if (eigtHVS == "72")
                {
                    mapperTextBox.Text = "72 - [Jaleco Early Mapper]";
                    exampleRomsTextBox.Text = "Pinball Quest (J), Moero!! Pro Tennis, Moero!! Juudou Warriors";
                }
                else if (eigtHVS == "73")
                {
                    mapperTextBox.Text = "73 - VRC3 [Konami VRC]";
                    exampleRomsTextBox.Text = "Salamander";
                }
                else if (eigtHVS == "74")
                {
                    mapperTextBox.Text = "74 - Pirate MMC3 variant [Taiwan MMC3]";
                    exampleRomsTextBox.Text = "Di 4 Ci - Ji Qi Ren Dai Zhan, Ji Jia Zhan Shi";
                }
                else if (eigtHVS == "75")
                {
                    mapperTextBox.Text = "75 - [JalecoMapper SS8805] [VRC1]";
                    exampleRomsTextBox.Text = "Tetsuwan Atom, Ganbare Goemon! - Karakuri Douchuu";
                }
                else if (eigtHVS == "76")
                {
                    mapperTextBox.Text = "76 - [Namco 109]";
                    exampleRomsTextBox.Text = "Digital Devil Story - Megami Tensei";
                }
                else if (eigtHVS == "77")
                {
                    mapperTextBox.Text = "77 - [Irem Early Mapper 0]";
                    exampleRomsTextBox.Text = "Napoleon Senki";
                }
                else if (eigtHVS == "78")
                {
                    mapperTextBox.Text = "78 - [74161/32]";
                    exampleRomsTextBox.Text = "Holy Diver, Uchuusen - Cosmo Carrier";
                }
                else if (eigtHVS == "79")
                {
                    mapperTextBox.Text = "79 - [American Video Ent.]";
                    exampleRomsTextBox.Text = "Blackjack, Dudes with Attitude, F-15 City War, Krazy Kreatures";
                }
                else if (eigtHVS == "80")
                {
                    mapperTextBox.Text = "80 - X-005 Chipset";
                    exampleRomsTextBox.Text = "Kyonshiizu 2, Minelvaton Saga, Taito Grand Prix - Eikou heno License";
                }
                else if (eigtHVS == "81")
                {
                    mapperTextBox.Text = "81 - C075 Chipset";
                    exampleRomsTextBox.Text = "";
                }
                else if (eigtHVS == "82")
                {
                    mapperTextBox.Text = "82 - X1-17 Chipset";
                    exampleRomsTextBox.Text = "SD Keiji - Blader, Kyuukyoku Harikiri Stadium";
                }
                else if (eigtHVS == "83")
                {
                    mapperTextBox.Text = "83 - Cony Mapper";
                    exampleRomsTextBox.Text = "";
                }
                else if (eigtHVS == "84")
                {
                    mapperTextBox.Text = "84 - PasoFami Mapper!";
                    exampleRomsTextBox.Text = "";
                }
                else if (eigtHVS == "85")
                {
                    mapperTextBox.Text = "85 - [Konami VRC 7]";
                    exampleRomsTextBox.Text = "Lagrange Point, Tiny Toon Adventures 2  (J)";
                }
                else if (eigtHVS == "86")
                {
                    mapperTextBox.Text = "86 - Mapper 86";
                    exampleRomsTextBox.Text = "Moero!! Pro Yakyuu (Black), Moero!! Pro Yakyuu (Red)";
                }
                else if (eigtHVS == "87")
                {
                    mapperTextBox.Text = "87 - [Mapper 87]";
                    exampleRomsTextBox.Text = "Argus (J), City Connection (J), Ninja Jajamaru Kun";
                }
                else if (eigtHVS == "88")
                {
                    mapperTextBox.Text = "88 - [Mapper 88]";
                    exampleRomsTextBox.Text = "Quinty (J), Namcot Mahjong 3, Dragon Spirit - Aratanaru Densetsu";
                }
                else if (eigtHVS == "89")
                {
                    mapperTextBox.Text = "89 - [Mapper 89]";
                    exampleRomsTextBox.Text = "Mito Koumon";
                }
                else if (eigtHVS == "90")
                {
                    mapperTextBox.Text = "90 - Tekken 2 Pirate Cart";
                    exampleRomsTextBox.Text = "Tekken 2, Mortal Kombat 2, Super Contra 3, Super Mario World";
                }
                else if (eigtHVS == "91")
                {
                    mapperTextBox.Text = "91 - [Mapper 91]";
                    exampleRomsTextBox.Text = "Street Fighter 3";
                }
                else if (eigtHVS == "92")
                {
                    mapperTextBox.Text = "92 - [mapper 92]";
                    exampleRomsTextBox.Text = "Moero!! Pro Soccer, Moero!! Pro Yakyuu '88 - Ketteiban";
                }
                else if (eigtHVS == "93")
                {
                    mapperTextBox.Text = "93 - [Mapper 93]";
                    exampleRomsTextBox.Text = "Fantasy Zone (J)";
                }
                else if (eigtHVS == "94")
                {
                    mapperTextBox.Text = "94 - [Mapper 94]";
                    exampleRomsTextBox.Text = "Senjou no Ookami";
                }
                else if (eigtHVS == "95")
                {
                    mapperTextBox.Text = "95 - MMC3  (modified)";
                    exampleRomsTextBox.Text = "Dragon Buster (J)";
                }
                else if (eigtHVS == "96")
                {
                    mapperTextBox.Text = "96 - Mapper 96";
                    exampleRomsTextBox.Text = "Oeka Kids - Anpanman no Hiragana Daisuki, Oeka Kids - Anpanman to Oekaki Shiyou!!";
                }
                else if (eigtHVS == "97")
                {
                    mapperTextBox.Text = "97 - [Mapper 97]";
                    exampleRomsTextBox.Text = "Kaiketsu Yanchamaru";
                }
                else if (eigtHVS == "100")
                {
                    mapperTextBox.Text = "100 - [Nestice -Buggy Mode]";
                    exampleRomsTextBox.Text = "";
                }
                else if (eigtHVS == "105")
                {
                    mapperTextBox.Text = "105 - [NES-EVENT]";
                    exampleRomsTextBox.Text = "Nintendo World Championships 1990";
                }
                else if (eigtHVS == "107")
                {
                    mapperTextBox.Text = "107 - [Mapper 107]";
                    exampleRomsTextBox.Text = "Magic Dragon";
                }
                else if (eigtHVS == "112")
                {
                    mapperTextBox.Text = "112 - [Mapper 112]";
                    exampleRomsTextBox.Text = "Huang Di San Guo Zhi - Qun Xiong Zheng Ba";
                }
                else if (eigtHVS == "113")
                {
                    mapperTextBox.Text = "113 - [Mapper 113]";
                    exampleRomsTextBox.Text = "Rad Racket - Deluxe Tennis II Papillion";
                }
                else if (eigtHVS == "115")
                {
                    mapperTextBox.Text = "115 - [MMC3 variant]";
                    exampleRomsTextBox.Text = "Yuu Yuu Hakusho Final - Makai Saikyou Retsuden";
                }
                else if (eigtHVS == "118")
                {
                    mapperTextBox.Text = "118 - [MMC3  (modified)]";
                    exampleRomsTextBox.Text = "Armadillo, Pro Sport Hockey";
                }                      
                else if (eigtHVS == "119")
                {
                    mapperTextBox.Text = "119 - MMC3 (alternate) [TQROM]";
                    exampleRomsTextBox.Text = "High Speed, Pinbot";
                }
                else if (eigtHVS == "140")
                {
                    mapperTextBox.Text = "140 - [Mapper 140]";
                    exampleRomsTextBox.Text = "Bio Senshi Dan - Increaser Tono Tatakai";
                }                
                else if (eigtHVS == "152")
                {
                    mapperTextBox.Text = "152 - [Mapper 152]";
                    exampleRomsTextBox.Text = "Arkanoid 2 (J), Gegege no Kitarou 2";
                }
                else if (eigtHVS == "154")
                {
                    mapperTextBox.Text = "154 - [Mapper 154]";
                    exampleRomsTextBox.Text = "Devil Man";
                }
                else if (eigtHVS == "159")
                {
                    mapperTextBox.Text = "159 - (Clone of Mapper 16) [Mapper 159]";
                    exampleRomsTextBox.Text = "Dragon Ball Z - Kyoushuu! Saiya Jin, SD Gundam Gaiden, Magical Taruruuto Kun 1, 2";
                }
                else if (eigtHVS == "164")
                {
                    mapperTextBox.Text = "164 - [Mapper 164]";
                    exampleRomsTextBox.Text = "Final Fantasy V";
                }
                else if (eigtHVS == "165")
                {
                    mapperTextBox.Text = "165 - [Mapper 165]";
                    exampleRomsTextBox.Text = "Fire Emblem (Unl)";
                }
                else if (eigtHVS == "180")
                {
                    mapperTextBox.Text = "180 - [Mapper 180]";
                    exampleRomsTextBox.Text = "Crazy Climber (J)";
                }
                else if (eigtHVS == "182")
                {
                    mapperTextBox.Text = "182 - (MMC3 Variant/Scrambled) [Mapper 182]";
                    exampleRomsTextBox.Text = "Pocahontas, Super Donkey Kong";
                }
                else if (eigtHVS == "184")
                {
                    mapperTextBox.Text = "184 - [Mapper 184]";
                    exampleRomsTextBox.Text = "Atlantis no Nazo, The Wing of Madoola";
                }
                else if (eigtHVS == "185")
                {
                    mapperTextBox.Text = "185 - [Mapper 185]";
                    exampleRomsTextBox.Text = "Spy Vs. Spy (J), Mighty Bomb Jack (J)";
                }
                else if (eigtHVS == "189")
                {
                    mapperTextBox.Text = "189 - (modified MMC3) [Mapper 189]";
                    exampleRomsTextBox.Text = "Thunder Warrior";
                }
                else if (eigtHVS == "191")
                {
                    mapperTextBox.Text = "191 - [Pirate MMC3 variant]";
                    exampleRomsTextBox.Text = "Sugoro Quest - Dice no Senshitachi (As)";
                }
                else if (eigtHVS == "192")
                {
                    mapperTextBox.Text = "192 - [Pirate MMC3 variant]";
                    exampleRomsTextBox.Text = "Ying Lie Qun Xia Zhuan";
                }
                else if (eigtHVS == "193")
                {
                    mapperTextBox.Text = "193 - [Mapper 193]";
                    exampleRomsTextBox.Text = "Fighting Hero (Unl)";
                }
                else if (eigtHVS == "194")
                {
                    mapperTextBox.Text = "194 - [Pirate MMC3 variant]";
                    exampleRomsTextBox.Text = "Dai-2-Ji - Super Robot Taisen (As)";
                }
                else if (eigtHVS == "200")
                {
                    mapperTextBox.Text = "200 - 1200-in-1, 36-in-1 [Mapper 200]";
                    exampleRomsTextBox.Text = "1200-in-1, 36-in-1";
                }
                else if (eigtHVS == "201")
                {
                    mapperTextBox.Text = "201 - [Mapper 201]";
                    exampleRomsTextBox.Text = "8-in-1, 21-in-1 (2006-CA) (Unl) ";
                }
                else if (eigtHVS == "203")
                {
                    mapperTextBox.Text = "203 - [Mapper 203]";
                    exampleRomsTextBox.Text = "35-in-1 ";
                }
                else if (eigtHVS == "205")
                {
                    mapperTextBox.Text = "205 - [Mapper 205]";
                    exampleRomsTextBox.Text = "15-in-1, 3-in-1";
                }
                else if (eigtHVS == "207")
                {
                    mapperTextBox.Text = "207 - [Mapper 207]";
                    exampleRomsTextBox.Text = "Fudou Myouou Den";
                }
                else if (eigtHVS == "209")
                {
                    mapperTextBox.Text = "209 - [Mapper 209]";
                    exampleRomsTextBox.Text = "Shin Samurai Spirits 2";
                }
                else if (eigtHVS == "210")
                {
                    mapperTextBox.Text = "210 - [Mapper 210]";
                    exampleRomsTextBox.Text = "Family Circuit '91, Wagyan Land 2,3, Dream Master";
                }
                else if (eigtHVS == "225")
                {
                    mapperTextBox.Text = "225 - [Mapper 225]";
                    exampleRomsTextBox.Text = "52 Games, 58-in-1, 64-in-1 ";
                }
                else if (eigtHVS == "226")
                {
                    mapperTextBox.Text = "226 - [Mapper 226]";
                    exampleRomsTextBox.Text = "76-in-1, Super 42-in-1 ";
                }
                else if (eigtHVS == "227")
                {
                    mapperTextBox.Text = "227 - [Mapper 227]";
                    exampleRomsTextBox.Text = "1200-in-1";
                }
                else if (eigtHVS == "228")
                {
                    mapperTextBox.Text = "228 - [Mapper 228]";
                    exampleRomsTextBox.Text = "Action 52, Cheetah Men II";
                }
                else if (eigtHVS == "230")
                {
                    mapperTextBox.Text = "230 - [Mapper 230]";
                    exampleRomsTextBox.Text = "22-in-1";
                }
                else if (eigtHVS == "231")
                {
                    mapperTextBox.Text = "231 - [Mapper 231]";
                    exampleRomsTextBox.Text = "20-in-1";
                }
                else if (eigtHVS == "232")
                {
                    mapperTextBox.Text = "232 - [Mapper 232]";
                    exampleRomsTextBox.Text = "Quattro Adventure, Quattro Sports, Quattro Arcade ";
                }
                else if (eigtHVS == "233")
                {
                    mapperTextBox.Text = "233 - [Mapper 233]";
                    exampleRomsTextBox.Text = "42-in-1";
                }
                else if (eigtHVS == "234")
                {
                    mapperTextBox.Text = "234 - [Mapper 234]";
                    exampleRomsTextBox.Text = "Maxi 15 (PAL)";
                }
                else if (eigtHVS == "240")
                {
                    mapperTextBox.Text = "240 - [Mapper 240]";
                    exampleRomsTextBox.Text = "Jing Ke Xin Zhuan, Sheng Huo Lie Zhuan";
                }
                else if (eigtHVS == "242")
                {
                    mapperTextBox.Text = "242 - [Mapper 242]";
                    exampleRomsTextBox.Text = "Wai Xing Zhan Shi";
                }
                else if (eigtHVS == "243")
                {
                    mapperTextBox.Text = "243 - [Mapper 243]";
                    exampleRomsTextBox.Text = "Honey, Poker III 5-in-1";
                }
                else if (eigtHVS == "245")
                {
                    mapperTextBox.Text = "245 - [Mapper 245]";
                    exampleRomsTextBox.Text = "Chu Han Zheng Ba - The War Between Chu & Han, Xing Ji Wu Shi - Super Fighter, Yin He Shi Dai, Yong Zhe Dou e Long - Dragon Quest VII (As), Dong Fang de Chuan Shuo - The Hyrule Fantasy";
                }
                else if (eigtHVS == "246")
                {
                    mapperTextBox.Text = "246 - [Mapper 246]";
                    exampleRomsTextBox.Text = "Fong Shen Bang - Zhu Lu Zhi Zhan";
                }
                else
                {
                    mapperTextBox.Text = "UNDEFINED";
                }
            }
            else
            {
                mapperString = eigtHVS;
                mapperInt = int.Parse(mapperString, System.Globalization.NumberStyles.HexNumber);
                eigtHVS = mapperInt.ToString();

                if (eigtHVS == "0")
                {
                    mapperTextBox.Text = "No Mapper [NROM]";
                    exampleRomsTextBox.Text = "Ice Climber, Excitebike, Balloon Fight, Super Mario Bros";
                }
                else if (eigtHVS == "1")
                {
                    mapperTextBox.Text = "1 - Nintendo MMC1 Chipset [MMC1] [S(x)ROM]";
                    exampleRomsTextBox.Text = "Final Fantasy, Mega Man 2, Blaster Master, Metroid, Kid Icarus, Zelda, Zelda 2, Castlevania 2";
                }
                else if (eigtHVS == "2")
                {
                    mapperTextBox.Text = "2 - ROM (PRG) Switch [U(x)ROM]";
                    exampleRomsTextBox.Text = "Mega Man, Castlevania, Contra, Duck Tales, Metal Gear";
                }
                else if (eigtHVS == "3")
                {
                    mapperTextBox.Text = "3 - VROM (CHR) Switch [CNROM]";
                    exampleRomsTextBox.Text = "Solomon's Key, Arkanoid, Arkista's Ring, Bump 'n' Jump, Cybernoid";
                }
                else if (eigtHVS == "4")
                {
                    mapperTextBox.Text = "4 - Nintendo MMC3 Chipset [MMC3] [T(x)ROM], [MMC6] (H(x)ROM]";
                    exampleRomsTextBox.Text = "Mega Man 3, 4, 5, 6, Kirby's Adventure, Gauntlet, Rad Racer 2, Startropics 1, 2 (MMC6), Super Mario Bros. 2, 3";
                }
                else if (eigtHVS == "5")
                {
                    mapperTextBox.Text = "5 - Nintendo MMC5 Chipset [MMC5] [E(x)ROM]";
                    exampleRomsTextBox.Text = "Castlevania 3, Just Breed, Uncharted Waters, Romance of the 3 Kingdoms 2, Laser Invasion, Metal Slader Glory, Uchuu Keibitai SDF, Shin 4 Nin Uchi Mahjong - Yakuman Tengoku";
                }
                else if (eigtHVS == "6")
                {
                    mapperTextBox.Text = "6 - FFE F4XXX Games";
                }
                else if (eigtHVS == "7")
                {
                    mapperTextBox.Text = "7 - 32kb ROM (PRG) Switch [A(x)ROM]";
                    exampleRomsTextBox.Text = "Battletoads, Time Lord, Marble Madness";
                }
                else if (eigtHVS == "8")
                {
                    mapperTextBox.Text = "8 - FFE F3XXX Games";
                }
                else if (eigtHVS == "9")
                {
                    mapperTextBox.Text = "9 - Nintendo MMC2 Chipset [MMC2] [P(x)ROM]";
                    exampleRomsTextBox.Text = "Mike Tyson's Punch Out!!";
                }
                else if (eigtHVS == "10")
                {
                    mapperTextBox.Text = "10 - Nintendo MMC4 Chipset [MMC4]";
                    exampleRomsTextBox.Text = "Fire Emblem";
                }
                else if (eigtHVS == "11")
                {
                    mapperTextBox.Text = "11 - Color Dreams Chipset";
                    exampleRomsTextBox.Text = "Crystal Mines, Metal Fighter";
                }
                else if (eigtHVS == "12")
                {
                    mapperTextBox.Text = "12 - FFE F6XXX Games";
                }
                else if (eigtHVS == "13")
                {
                    mapperTextBox.Text = "13 - [CPROM]";
                    exampleRomsTextBox.Text = "Videomation";
                }
                else if (eigtHVS == "15")
                {
                    mapperTextBox.Text = "15 - 100-in-1 Cart Switch";
                    exampleRomsTextBox.Text = "100-in-1 Contra Function 16";
                }
                else
                {
                    mapperTextBox.Text = "[UNDEFINED]";
                }
            }

            if (nintHVS == "0")
            {
                mirroringTextBox.Text = "[Horizontal Mirroring ONLY]";
                trainerTextBox.Text = "[NONE]";
                vramTextBox.Text = "[N/A]";
                batteryTextBox.Text = "NO";
            }
            else if (nintHVS == "1")
            {
                mirroringTextBox.Text = "[Vertical Mirroring]";
                trainerTextBox.Text = "[NONE]";
                vramTextBox.Text = "[N/A]";
                batteryTextBox.Text = "NO";
            }
            else if (nintHVS == "2")
            {
                mirroringTextBox.Text = "[Horizontal Mirroring]";
                trainerTextBox.Text = "[NONE]";
                vramTextBox.Text = "[N/A]";
                batteryTextBox.Text = "YES";
            }
            else if (nintHVS == "3")
            {
                mirroringTextBox.Text = "[Vertical Mirroring]";
                trainerTextBox.Text = "[NONE]";
                vramTextBox.Text = "[N/A]";
                batteryTextBox.Text = "YES";
            }
            else if (nintHVS == "4")
            {
                mirroringTextBox.Text = "[Horizontal Mirroring]";
                trainerTextBox.Text = "YES";
                vramTextBox.Text = "[N/A]";
                batteryTextBox.Text = "NO";
            }
            else if (nintHVS == "5")
            {
                mirroringTextBox.Text = "[Vertical Mirroring]";
                trainerTextBox.Text = "YES";
                vramTextBox.Text = "[N/A]";
                batteryTextBox.Text = "NO";
            }
            else if (nintHVS == "6")
            {
                mirroringTextBox.Text = "[Horizontal Mirroring]";
                trainerTextBox.Text = "YES";
                vramTextBox.Text = "[N/A]";
                batteryTextBox.Text = "YES";
            }
            else if (nintHVS == "7")
            {
                mirroringTextBox.Text = "[Vertical Mirroring]";
                trainerTextBox.Text = "YES";
                vramTextBox.Text = "[N/A]";
                batteryTextBox.Text = "YES";
            }
            else if (nintHVS == "8")
            {
                mirroringTextBox.Text = "[Horizontal Mirroring]";
                trainerTextBox.Text = "[NONE]";
                vramTextBox.Text = "[4 Screen VRAM]";
                batteryTextBox.Text = "YES";
            }
            else if (nintHVS == "9")
            {
                mirroringTextBox.Text = "[Vertical Mirroring]";
                trainerTextBox.Text = "[NONE]";
                vramTextBox.Text = "[4 Screen VRAM]";
                batteryTextBox.Text = "YES";
            }
            else if (nintHVS == "A")
            {
                mirroringTextBox.Text = "[Horizontal Mirroring]";
                trainerTextBox.Text = "[NONE]";
                vramTextBox.Text = "[4 Screen VRAM]";
                batteryTextBox.Text = "YES";
            }
            else if (nintHVS == "B")
            {
                mirroringTextBox.Text = "[Vertical Mirroring]";
                trainerTextBox.Text = "YES";
                vramTextBox.Text = "[4 Screen VRAM]";
                batteryTextBox.Text = "YES";
            }
            else if (nintHVS == "C")
            {
                mirroringTextBox.Text = "[Horizontal Mirroring]";
                trainerTextBox.Text = "YES";
                vramTextBox.Text = "[4 Screen VRAM]";
                batteryTextBox.Text = "YES";
            }
            else if (nintHVS == "D")
            {
                mirroringTextBox.Text = "[Vertical Mirroring]";
                trainerTextBox.Text = "YES";
                vramTextBox.Text = "[4 Screen VRAM]";
                batteryTextBox.Text = "YES";
            }
            else if (nintHVS == "E")
            {
                mirroringTextBox.Text = "[Horizontal Mirroring]";
                trainerTextBox.Text = "YES";
                vramTextBox.Text = "[4 Screen VRAM]";
                batteryTextBox.Text = "YES";
            }
            else if (nintHVS == "F")
            {
                mirroringTextBox.Text = "[Vertical Mirroring]";
                trainerTextBox.Text = "YES";
                vramTextBox.Text = "[4 Screen VRAM]";
                batteryTextBox.Text = "YES";
            }

            }


        private void cleanRomButton_Click(object sender, EventArgs e)
        {

            string s  = "\0\0\0\0\0\0\0\0\0";
                byte[] g = Encoding.Default.GetBytes(s);
                long offset;
                    offset = Convert.ToInt64("7");
                    editFile(path, offset, g);
                openFlagString = "1";
                openToolStripMenuItem_Click(sender, e);

        }

        public void editFile(string path, long offset, byte[] g)
        {
            FileStream f = new FileStream(path, FileMode.Open);
            f.Seek(offset, SeekOrigin.Begin);
            f.Write(g, 0, g.Length);
            f.Close();
        }

        private void mainForm_Load(object sender, EventArgs e)
        {
            openFlagString = "0";
        }

        private void remove16byteHeaderCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            if (remove16byteHeaderCheckBox.Checked)
            {
                chrprgCheckBox.Enabled = true;
            }
            else
            {
                chrprgCheckBox.Enabled = false;
                chrprgCheckBox.Checked = false;
            }
        }

        private void chrprgCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            if (chrprgCheckBox.Checked)
            {
                autoSplitChrPrgRadioButton.Enabled = true;
                manualSplitPrgChrRadioButton.Enabled = true;

                autoSplitChrPrgRadioButton.Checked = true;
            }
            else
            {
                autoSplitChrPrgRadioButton.Enabled = false;
                manualSplitPrgChrRadioButton.Enabled = false;
                prgSizeSplitTextBox.Enabled = false;
                chrSizeSplitTextBox.Enabled = false;

                autoSplitChrPrgRadioButton.Checked = false;
                manualSplitPrgChrRadioButton.Checked = false;
            }
        }

        private void autoSplitChrPrgRadioButton_CheckedChanged(object sender, EventArgs e)
        {
            if (autoSplitChrPrgRadioButton.Checked)
            {
                prgSizeSplitTextBox.Enabled = false;
                chrSizeSplitTextBox.Enabled = false;
            }

        }

        private void manualSplitPrgChrRadioButton_CheckedChanged(object sender, EventArgs e)
        {
            if (manualSplitPrgChrRadioButton.Checked)
            {
                prgSizeSplitTextBox.Enabled = true;
                chrSizeSplitTextBox.Enabled = true;
            }
        }

        private void analyzeRomToolStripMenuItem_Click(object sender, EventArgs e)
        {
            analyzeRomButton_Click(sender, e);
        }

        private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AboutBox1 aboutBox = new AboutBox1();

            aboutBox.ShowDialog();
        }

        private void copyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (hexTextBox.SelectionLength == 0)
            {
                hexTextBox.SelectAll();
            }

            hexTextBox.Copy();
        }




    }
    }
